package com.fitness.front.controller;

import com.fitness.front.modal.member.vo.MemberVO;
import com.fitness.front.modal.message.vo.MessageVO;
import com.fitness.front.modal.response.ServerResponseEntity;
import com.fitness.front.service.IMessageService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/front/message")
public class MessageController {

    private final IMessageService messageService;

    /**
     * 获取消息
     */
    @GetMapping("/list")
    public ServerResponseEntity<List<MessageVO>> messageList(@RequestParam("from") Long from,@RequestParam("to") Long to) {
        List<MessageVO> result = messageService.messageList(from,to);
        return ServerResponseEntity.success(result);
    }

    /**
     * 获取消息列表用户
     */
    @GetMapping("/messageMembers")
    public ServerResponseEntity<List<MemberVO>> messageMembers(Long memberId) {
        List<MemberVO> result = messageService.messageMembers(memberId);
        return ServerResponseEntity.success(result);
    }

    /**
     * 判断是否有消息
     */
    @GetMapping("/noReadMessageCount")
    public ServerResponseEntity<Integer> noReadMessageCount(Long memberId) {
        Integer result = messageService.noReadMessageCount(memberId);
        return ServerResponseEntity.success(result);
    }
}
